package com.ds.infrastructure.hyperspace.container.internal.operator;

import com.ds.infrastructure.hyperspace.common.Operator;
import org.springframework.util.StringUtils;

/**
 * @author  Weishaoying
 */
public abstract class AbstractOperator implements Operator {

    @Override
    public String[] prepareArgs(String[] args) {
        if (args == null || args.length < getOperatorArgsLength()) {
            return null;
        }
        String[] argArray;
        String argStr = args[0];
        if (argStr.indexOf(OR_DELIMITER) == -1) {
            argArray = new String[1];
            argArray[0] = argStr;
        } else {
            argArray = StringUtils.delimitedListToStringArray(
                    argStr, OR_DELIMITER);
        }
        return argArray;
    }

}
